# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=gspell
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.8.3
pkgrel=2
arch=('any')
pkgdesc="Spell-checking library for GTK applications (mingw-w64)"
options=(strip staticlibs)
depends=("${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-iso-codes"
         "${MINGW_PACKAGE_PREFIX}-enchant")
makedepends=("${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection")
license=("LGPL 2.1")
url="https://www.gnome.org"
source=(https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz)
sha256sums=('5ae514dd0216be069176accf6d0049d6a01cfa6a50df4bc06be85f7080b62de8')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}

  autoreconf -fiv
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST} && cd build-${MINGW_CHOST}

  mkdir -p docs/reference/html
  cp -rf ../${_realname}-${pkgver}/docs/reference/html/* docs/reference/html

  ../${_realname}-${pkgver}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --enable-introspection
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"

  make DESTDIR=${pkgdir} install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
